package sample.service.config.impl;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.configuration.BaseConfiguration;
import org.springframework.stereotype.Service;

import sample.intf.service.config.IConfigService;

@Service
public class ConfigService implements IConfigService {

	@Resource
	BaseConfiguration runtimeConfiguration;

	@Override
	public String getArticlePictureRootPath(HttpServletRequest request) {
		String path = runtimeConfiguration.getString("usercontents.articlepictures.rootpath");
		if (path != null && !"".equals(path.trim()))
			return path;
		if (request != null)
			return request.getServletContext().getRealPath("usercontents/article_pictures");
		return null;
	}
}
